package com.wish.system.api.factory;

import com.wish.system.api.RemoteMessageService;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 短信降级处理
 *
 * @author dingshiyu
 */
@Component
public class RemoteMessageFallbackFactory implements FallbackFactory<RemoteMessageService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteMessageFallbackFactory.class);


    //短信服务熔断
    @Override
    public RemoteMessageService create(Throwable throwable) {
        log.error("短信调用失败:{}", throwable.getMessage());

        return new RemoteMessageService() {
            @Override
            public boolean send(String phoneNumber, String templateId) {

                System.err.println("短信调用失败");

                return false;
            }
        };


    }
}
